{template '_header'}
<style>
    .form-horizontal .form-group {
        margin-right: -50px;
    }

    .col-sm-9 {
        padding-right: 0;
    }

    .tm .btn {
        margin-bottom: 5px;
    }

    .table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th {
        padding: 0;
        margin: 0;
        border: 0;
        text-overflow: clip;
    }
</style>

<div class="page-header">
    当前位置：
    <span class="text-primary">{if !empty($item['id'])}编辑{else}添加{/if}支付信息
        <small>{if !empty($item['id'])}修改【{$item['title']}】{/if}</small>
    </span>
</div>

<div class="page-content">
    <div class="row">
        <div class="col-sm-12">
            <form {ife 'sysset.payment' $list}action="" method="post"{/if} class="form-horizontal form-validate" enctype="multipart/form-data">
                <div class="form-group">
                    <label class="col-lg control-label must">支付名称</label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'sysset.payment' $data}
                        <input type="text" name="title" class="form-control" value="{$data['title']}" placeholder="方便选择与记忆的支付名称" data-rule-required='true'/>
                        {else}
                        <div class='form-control-static'>{$data['title']}</div>
                        {/if}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg control-label must">支付类型</label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'sysset.payment' $data}
                        <select class="form-control tpl-category-parent" name="type" id="type">
                            {loop $payment $key $val}
                            <option value="{$key}" {if $data['type']==$key}selected="true"{/if}>{$val}</option>
                            {/loop}
                        </select>
                        {else}
                        <div class='form-control-static'>{$payment[$data['type']]}</div>
                        {/if}
                    </div>
                </div>

                <div class="form-group hidden merch">
                    <label class="col-lg control-label must">服务商公众号(AppId)</label>
                    <div class="col-sm-9">
                        {ifp 'sysset.payment.edit'}
                        <input type="text" name="appid" class="form-control" value="{$data['appid']}"/>
                        {else}
                        <div class='form-control-static'>{$data['appid']}</div>
                        {/if}
                    </div>
                </div>

                <div class="form-group hidden merch">
                    <label class="col-lg control-label must">服务商支付商户号(Mch_Id)</label>
                    <div class="col-sm-9">
                        {ifp 'sysset.payment.edit'}
                        <input type="text" name="mch_id" class="form-control" value="{$data['mch_id']}"/>
                        {else}
                        <div class='form-control-static'>{$data['mch_id']}</div>
                        {/if}
                    </div>
                </div>

                <div class="form-group hidden wechat">
                    <label class="col-lg control-label must">公众号(AppId)</label>
                    <div class="col-sm-9">
                        {ifp 'sysset.payment.edit'}
                        <input type="text" name="sub_appid" class="form-control" value="{$data['sub_appid']}"/>
                        {else}
                        <div class='form-control-static'>{$data['sub_appid_sub']}</div>
                        {/if}
                    </div>
                </div>

                <div class="form-group hidden" id="sub_appsecret">
                    <label class="col-lg control-label">应用密钥(AppSecret)</label>
                    <div class="col-sm-9">
                        {ifp 'sysset.payment.edit'}
                        <input type="text" name="sub_appsecret" class="form-control" value="{$data['sub_appsecret']}"/>
                        <div class="help-block">只有借用支付公众号绑定了系统或者支付目录和授权站点都是本站的设定,才需要填写此项</div>
                        {else}
                        <div class='form-control-static'>{$data['sub_appsecret']}</div>
                        {/if}
                    </div>
                </div>

                <div class="form-group" >
                    <label class="col-lg control-label must">支付商户号(Mch_Id)</label>
                    <div class="col-sm-9">
                        {ifp 'sysset.payment.edit'}
                        <input type="text" name="sub_mch_id" class="form-control" value="{$data['sub_mch_id']}"/>
                        {else}
                        <div class='form-control-static'>{$data['sub_mch_id']}</div>
                        {/if}
                    </div>
                </div>

                <div class="form-group" >
                    <label class="col-lg control-label must">支付密钥(APIKEY)</label>
                    <div class="col-sm-9">
                        {ifp 'sysset.payment.edit'}
                        <input type="text" name="apikey" class="form-control" value="{$data['apikey']}"/>
                        <div class="help-block">服务商的 APIKEY,并不是子商户的APIKEY</div>
                        {else}
                        <div class='form-control-static'>{$data['apikey_sub']}</div>
                        {/if}
                    </div>
                </div>

                <div class="form-group hidden" id="is_raw">
                    <label class="col-lg control-label">是否原生支付</label>
                    <div class="col-sm-9 col-xs-12">
                        {ifp 'sysset.payment.edit'}
                        <label class='radio radio-inline'>
                            <input type='radio' value='0' name='is_raw' {if $data['is_raw']==0}checked{/if} /> 否
                        </label>
                        <label class='radio radio-inline'>
                            <input type='radio' value='1' name='is_raw'  {if $data['is_raw']=='1'}checked{/if} /> 是
                        </label>
                        {else}
                        <div class='form-control-static'>{if $data['set_realname']==1}隐藏{else}显示{/if}</div>
                        {/if}
                    </div>
                </div>

                <div class="form-group hidden cert">
                    <label class="col-lg control-label">CERT证书文件</label>
                    <div class="col-sm-9 col-xs-12">
                        {ifp 'sysset.payment.edit'}
                        <input type="file" name="cert_file" class="form-control" />
                        <span class="help-block">
                                            {if !empty($data['cert_file'])}
                                            <span class='label label-success'>已上传</span>
                                            {else}
                                            <span class='label label-danger'>未上传</span>
                                            {/if}
                                            下载证书 cert.zip 中的 apiclient_cert.pem 文件</span>
                        {else}
                        {if !empty($data['cert_file'])}
                        <span class='label label-success'>已上传</span>
                        {else}
                        <span class='label label-danger'>未上传</span>
                        {/if}
                        {/if}
                    </div>
                </div>
                <div class="form-group hidden cert">
                    <label class="col-lg control-label">KEY密钥文件</label>
                    <div class="col-sm-9 col-xs-12">
                        {ifp 'sysset.payment.edit'}
                        <input type="file" name="key_file" class="form-control" />
                        <span class="help-block">
                                           {if !empty($data['key_file'])}
                                            <span class='label label-success'>已上传</span>
                                            {else}
                                            <span class='label label-danger'>未上传</span>
                                            {/if}
                                            下载证书 cert.zip 中的 apiclient_key.pem 文件
                                        </span>
                        {else}
                        {if !empty($data['key_file'])}
                        <span class='label label-success'>已上传</span>
                        {else}
                        <span class='label label-danger'>未上传</span>
                        {/if}
                        {/if}
                    </div>
                </div>
                <div class="form-group hidden cert">
                    <label class="col-lg control-label">ROOT文件</label>
                    <div class="col-sm-9 col-xs-12">
                        {ifp 'sysset.payment.edit'}
                        <input type="file" name="root_file" class="form-control" />
                        <span class="help-block">
                                          {if !empty($data['root_file'])}
                                            <span class='label label-success'>已上传</span>
                                            {else}
                                            <span class='label label-danger'>未上传</span>
                                            {/if}
                                            下载证书 cert.zip 中的 rootca.pem 文件
                                        </span>
                        {else}
                        {if !empty($data['root_file'])}
                        <span class='label label-success'>已上传</span>
                        {else}
                        <span class='label label-danger'>未上传</span>
                        {/if}
                        {/if}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg control-label"></label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'sysset.payment' $list}
                        <input type="submit" value="提交" class="btn btn-primary"/>
                        {/if}
                        <a class="btn btn-default " href="{php echo webUrl('sysset/payment')}">返回列表</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
    $(function () {
        var type = $("#type");
        type.change(function (e) {
            var $this = $(this);
            var cert = $(".cert");
            var merch = $(".merch");
            var wechat = $(".wechat");
            var is_raw = $("#is_raw");
            var sub_appsecret = $("#sub_appsecret");
            cert.addClass('hidden');
            merch.addClass('hidden');
            wechat.addClass('hidden');
            is_raw.addClass('hidden');
            sub_appsecret.addClass('hidden');
            switch ($this.val())
            {
                case '0':
                    cert.removeClass('hidden');
                    wechat.removeClass('hidden');
                    break;
                case '1':
                    merch.removeClass('hidden');
                    cert.removeClass('hidden');
                    wechat.removeClass('hidden');
                    break;
                case '2':
                    cert.removeClass('hidden');
                    wechat.removeClass('hidden');
                    sub_appsecret.removeClass('hidden');
                    break;
                case '3':
                    merch.removeClass('hidden');
                    cert.removeClass('hidden');
                    wechat.removeClass('hidden');
                    sub_appsecret.removeClass('hidden');
                    break;
                case '4':
                    is_raw.removeClass('hidden');
                    break;

            }
        });
        type.trigger('change');
    });
</script>

{template '_footer'}
